package com.hongye.proprietary.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongye.proprietary.entity.MenuHomeEntity;
import com.hongye.proprietary.service.MenuHomeService;
import com.hongye.common.utils.PageUtils;
import com.hongye.common.utils.R;



/**
 * 经纪人首页菜单
 *
 * @author lins
 * @email 695565697@qq.com
 * @date 2021-10-14 11:16:47
 */
@RestController
@RequestMapping("proprietary/menuhome")
public class MenuHomeController {
    @Autowired
    private MenuHomeService menuHomeService;

    /**
     * 经纪人小程序端-首页数据提供接口 (业务块栏目数据，名称，图片地址，链接)
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = menuHomeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{menuId}")
    public R info(@PathVariable("menuId") Integer menuId){
		MenuHomeEntity menuHome = menuHomeService.getById(menuId);

        return R.ok().put("menuHome", menuHome);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MenuHomeEntity menuHome){
		menuHomeService.save(menuHome);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MenuHomeEntity menuHome){
		menuHomeService.updateById(menuHome);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] menuIds){
		menuHomeService.removeByIds(Arrays.asList(menuIds));

        return R.ok();
    }

}
